public class SharedVariable2 {
    private int sharedVariable = 0;

    synchronized public int action(int v) {
        if (v == 3) {
            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            sharedVariable = v;
        }
        return sharedVariable;
    }
}
